<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="breadcrumbs">
            <h:form>
                <a href="index.xhtml">Website Admin</a><div class="breadcrumb_divider"></div>
                <h:commandLink action="#{messagesController.prepareList()}" value="Messages" class="current"/>
            </h:form>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" id="form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorClass="errorStyle" infoClass="infoStyle" layout="table" >
                    </h:messages>
                </h:panelGroup>

                <h:outputText escape="false" value="No messages item found" rendered="#{messagesController.items.rowCount == 0}" class="infoStyle"> 
                </h:outputText>
                <article class="module width_full">
                    <header><h3>Messages</h3></header>
                    <div class="module_content">
                        <div class="tab_container">
                                <div id="tab1" class="tab_content">
                        <h:panelGroup rendered="#{messagesController.items.rowCount > 0}">
                            
                            <p:dataTable value="#{messagesController.items}" var="item" paginator="true" rows="50" 
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                         rowsPerPageTemplate="50,100,200" style="width: 100%" styleClass="tablesorter" >
                                <p:column rendered="#{item.userId == null}">
                                    <f:facet name="header">
                                        <h:outputText value="Exam code"/>
                                    </f:facet>
                                    <h:commandLink value="#{item.registerId.id.examId.examId}" action="#{messagesController.prepareEdit}" rendered="#{!item.status}" style="color: #00A2D3;">
                                        <f:setPropertyActionListener value="#{item}" target="#{messagesController.selected}" />
                                    </h:commandLink>
                                    <h:outputText value="#{item.registerId.id.examId.examId}" rendered="#{item.status}"/>
                                </p:column>
                                <p:column rendered="#{item.userId == null}">
                                    <f:facet name="header">
                                        <h:outputText value="Roll No."/>
                                    </f:facet>
                                    <h:outputText value="#{item.registerId.id.studentId.enRoll}" rendered="#{!item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="#{item.registerId.id.studentId.enRoll}" rendered="#{item.status}" />
                                </p:column>
                                <p:column rendered="#{item.userId == null}">
                                    <f:facet name="header">
                                        <h:outputText value="Student name"/>
                                    </f:facet>
                                    <h:outputText value="#{item.registerId.id.studentId.stuName}" rendered="#{!item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="#{item.registerId.id.studentId.stuName}" rendered="#{item.status}"/>
                                </p:column>
                                
                                <p:column rendered="#{item.userId != null}">
                                    <f:facet name="header">
                                        <h:outputText value="Exam code"/>
                                    </f:facet>
                                    
                                    <h:commandLink value="#{item.registerId.id.examId.examId}" action="#{messagesController.prepareEdit}" rendered="#{item.registerId != null and !item.status}" style="color: #00A2D3;">
                                        <f:setPropertyActionListener value="#{item}" target="#{messagesController.selected}" />
                                    </h:commandLink>
                                    <h:commandLink value="#{item.examId.examId}" action="#{messagesController.prepareEdit}" rendered="#{item.examId != null and !item.status}" style="color: #00A2D3;">
                                        <f:setPropertyActionListener value="#{item}" target="#{messagesController.selected}" />
                                    </h:commandLink>
                                    <h:outputText value="#{item.registerId.id.examId.examId}" rendered="#{item.registerId != null and item.status}" />
                                    <h:outputText value="#{item.examId.examId}" rendered="#{item.examId != null and item.status}" />
                                </p:column>
                                <p:column rendered="#{item.userId != null}">
                                    <f:facet name="header">
                                        <h:outputText value="Roll No."/>
                                    </f:facet>
                                    <h:outputText value="#{item.registerId.id.studentId.enRoll}"  rendered="#{item.registerId != null and !item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="Mutiple" rendered="#{item.examId != null and !item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="#{item.registerId.id.studentId.enRoll}"  rendered="#{item.registerId != null and item.status}" />
                                    <h:outputText value="Mutiple" rendered="#{item.examId != null and item.status}" />
                                </p:column>
                                <p:column rendered="#{item.userId != null}">
                                    <f:facet name="header">
                                        <h:outputText value="Student name"/>
                                    </f:facet>
                                    <h:outputText value="#{item.registerId.id.studentId.stuName}" rendered="#{item.registerId != null and !item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="Mutiple" rendered="#{item.examId != null and !item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="#{item.registerId.id.studentId.stuName}" rendered="#{item.registerId != null and item.status}" />
                                    <h:outputText value="Mutiple" rendered="#{item.examId != null and item.status}"/>
                                </p:column>
                                
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Message"/>
                                    </f:facet>
                                    <h:outputText value="#{item.messages}" rendered="#{!item.status}" style="color: #00A2D3;"/>
                                    <h:outputText value="#{item.messages}" rendered="#{item.status}" />
                                </p:column>
                           </p:dataTable>
                        </h:panelGroup>
                        </div></div>
                    </div></article>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
